<?php 
	session_start();
	include '../controller/buscaTwitter.php';	
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br" xml:lang="pt-br">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Sistema de Busca</title>
	<style type="text/css">
		html, body {
			height: 100%;
			font-family: sans-serif;
		}
		#divTudo {
			min-height: 100%;
			position: relative;
		}
		* html #divTudo{
			height: 100%; /* hack para IE6 que trata height como min-height */
		}
		#ulMenu {
			margin: 0; 
			padding: 0;	
			float: left;
			width: 100%;
			background-color: #F35A25;
			list-style-type: none;
		}
		#ulMenu li {
			display: inline;
		}
		#ulMenu li a {		
			padding: 3px 30px;			
			float: left;
			/* Visual do link */
			background-color: #F35A25;
			color: #333;
			text-decoration: none;
			border-bottom: 3px solid #F35A25;
		}
		#ulMenu li a:HOVER {
			background-color: #C95730;
			color: #FFFFFF;
			border-bottom: 3px solid #EA0000;			
		}
		#divConteudo{
			padding-bottom: 30px;
		}
		#divFooter{			
			background-color: #F35A25;
			position: absolute;
			width: 100%;
			bottom: 0;
		}		
	</style>
</head>
<body>	
	<div id="divMenu">
			<ul id="ulMenu">
				<li><a href="formBusca.php">Busca</a></li>
				<li><a href="principal.php">Relatórios</a></li>
				<li><a href="../index.php">Sair</a></li>
			</ul>
		</div>
		<div id="divConteudo">
			<div>
	        <form method="post" action="formBusca.php">
	            <label id="palavra">Digite a palavra-chave:</label>
	            <input type="text" id="keyword" name="keyword" />                
	            <input type="submit" value="Buscar" />            
	        </form>
    </div>        
        <?php 
        /** 
         * Faz include somente se houver retorno, caso contr�rio n�o exibe nada.
         * Se a busca n�o encontrar nenhum resultado, exibe a div de b
         */
        $busca = new BuscaTwitter();
        $phpObj = $busca->busca($_POST['keyword']);
        //echo $_POST['keyword']."<br/>";
        //echo $phpObj['query']['count'];
        //echo "<br />";        
        $valorArray = count($phpObj["query"]);
        if ($phpObj["query"]["count"] == 0 && $_POST['keyword'] == ""){			
     	        	      
        }
        elseif ($phpObj["query"]["count"] == 0 && $_POST['keyword'] != "") { ?>
    <div>
       	<h3>
       		<p>N�o foi encontrado resultado para essa busca!</p>                		        		
       	</h3>
    </div>
        <?php 	
        }
        elseif ($phpObj["query"]["count"] != 0) { 	
        	
        	//Grava o resultado da busca na session.
        	$_SESSION['retorno'] = $phpObj;
        	
        	//Faz o include do arquivo que ir� processar o retorno.        	
        	include 'formResultado.php';     		
        	
        }?>
	</div>
</body>
</html>